﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SarkothFarmer.Settings;
using Zeta;
using Zeta.Common;
using Zeta.CommonBot;
using Zeta.Internals.Actors;
using Zeta.Internals.Actors.Gizmos;
using Zeta.Internals.SNO;

namespace SarkothFarmer.Helpers
{
    class Objects
    {
        public static Vector3 HotspotSarkoth
        {
            get
            {
                switch (ZetaDia.Me.ActorClass)
                {
                    case ActorClass.Monk:
                        return hotspotSarkoth;
                    case ActorClass.Barbarian:
                        return new Vector3(118.0499f, 131.2448f, 0.1000005f);
                    case ActorClass.WitchDoctor:
                        return hotspotSarkoth;
                    case ActorClass.Wizard:
                        return hotspotSarkothDoor;
                    case ActorClass.DemonHunter:
                        return new Vector3(111.7733f, 156.4565f, 0.1000003f);
                    default:
                        return hotspotSarkoth;
                }
            }
        }
        public static Vector3 hotspotSarkothDoor = new Vector3(119.1499f, 135.3148f, 0.1000005f);
        public static Vector3 hotspotSarkoth = new Vector3(119.5718f, 106.2666f, 0.100001f);
        public static Vector3 HotspotScout
        {
            get
            {
                switch (ZetaDia.Me.ActorClass)
                {
                    case ActorClass.Wizard:
                        return new Vector3(2020.467f, 2540.79f, 27.1f);
                    case ActorClass.Barbarian:
                        return new Vector3(2021.882f, 2553.08f, 27.1f);
                    default:
                        return new Vector3(2021.738f, 2566.262f, 27.1f);
                }
            }
        }
        public static Vector3 HotspotCellarPortal
        {
            get { return new Vector3(2065.649f,2477.595f,27.31525f); }
        }
        public static GizmoPortal DankCellar
        {
            get
            {
                return
                    ZetaDia.Actors.GetActorsOfType<GizmoPortal>().FirstOrDefault(
                        w => w.ActorSNO == 176007);
            }
        }

        public static IOrderedEnumerable<DiaItem> Gold
        {
            get
            {
                ZetaDia.Actors.Update();
                return
                    ZetaDia.Actors.GetActorsOfType<DiaItem>().Where(
                        i =>
                        i.CommonData.Gold > Main.settingsWrapper.PickupGold &&
                        !ClassSpecifics.Common.Blacklist.Contains(i)).
                        OrderBy(i => i.Distance);
            }
        }

        public static DiaUnit Sarkoth
        {
            get { return ZetaDia.Actors.GetActorsOfType<DiaUnit>().FirstOrDefault(u => u.ActorSNO == 201878); }
        }

        public static IOrderedEnumerable<DiaItem> Loots
        {
            get
            {
                ZetaDia.Actors.Update();
                return
                    ZetaDia.Actors.GetActorsOfType<DiaItem>().Where(
                        i =>
                        i.CommonData.Gold == 0 && ItemManager.EvaluateItem(i.CommonData, ItemManager.RuleType.PickUp) &&
                        i.Distance <= Composites.LootRadius && !ClassSpecifics.Common.Blacklist.Contains(i)).OrderBy(
                            i => i.Distance);
            }
        }

        public static IOrderedEnumerable<DiaUnit> Units
        {
            get
            {
                ZetaDia.Actors.Update();
                return
                    ZetaDia.Actors.GetActorsOfType<DiaUnit>().Where(
                        x =>
                        x != null && x.Distance <= Composites.KillRadius &&
                        x.MonsterInfo.MonsterType != MonsterType.Team &&
                        x.SummonedByACDId != ZetaDia.Me.CommonData.DynamicId &&
                        x.MonsterInfo.MonsterType != MonsterType.Helper && x.MonsterInfo.MonsterType != MonsterType.Ally &&
                        x.ACDGuid != -1 && !x.IsDead).OrderBy(x => x.Distance);
            }
        }
    }
}
